<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Js对象String</title>
</head>
<body>
    
</body>
<script>
    //创建方式
    var s = new String("This is a A");
    var s2 = " This is a B ";
    console.log(s);
    console.log(s2);

    //属性
    console.log(s2.length);

    //方法 charAt() indexOf() trim() substring()
    
    //获取指定位置字符
    console.log("****************")
    console.log(s2.charAt(2))
    console.log(s2.charAt(3))

    //返回字符串索引
    console.log(s2.indexOf("is"))
    
    //trim去除两边空格
    console.log(s2.trim());

    //substring获取子串
    console.log(s2.substring(1,5));
    

    



</script>
</html>